package comm;


import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;

public class User {
	
	protected final SimpleStringProperty qq=new SimpleStringProperty("no Login");
	protected final SimpleIntegerProperty oldScore=new SimpleIntegerProperty(0);
	protected final SimpleIntegerProperty nowScore=new SimpleIntegerProperty(0);
	protected final SimpleStringProperty nickName=new SimpleStringProperty("no Login");
	protected final SimpleIntegerProperty profit=new SimpleIntegerProperty(0);

	public User() {
		
	}
	protected User(User user) {
		this.qq.bind(user.qq);
		this.oldScore.bind(user.oldScore);
		this.nowScore.bind(user.nowScore);
		this.nickName.bind(user.nickName);
		this.profit.bind(user.profit);
	}
	public String getQq() {
		return qq.get();
	}
	public int getOldScore() {
		return oldScore.get();
	}
	public int getNowScore() {
		return nowScore.get();
	}
	
	public void setOldScore(int oldScore) {
		this.oldScore.set(oldScore);
	}
	
	public void setNowScore(int nowScore) {
		this.nowScore.set(nowScore);
	}
	@Override
	public int hashCode() {
		return qq.hashCode();
	}

	@Override
	public boolean equals(Object b) {
		return getQq().equals(((User)b).getQq());
	}
	
	public void computeProfit() {
		setProfit(nowScore.get()-oldScore.get());
	}
	
	public int getProfit() {
		return profit.get();
	}
	
	public void setProfit(int profit) {
		this.profit.set(profit);
	}
}
